﻿using AudioStudio;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Yoozoo.Managers.ResourceManagerV2.Runtime;
namespace MouthAnimationFrame {
    public class TestMouthAnimation : MonoBehaviour
    {
        GameObject obj;
        Animator anim;

        public string audioEvent = "Dia_12_Bev";

        // Update is called once per frame
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.G))
            {
                if (obj == null)
                {
                    ResLoader refSet = ResLoader.Alloc();
                    //加载口型数据
                    refSet.Add2Load("Assets/ResourcesAssets/Prefabs/Character/Hero/PlayerModel/Person/male_base_white_01.prefab", (bool success, string assetName, object asset) =>
                    {
                        GameObject player = asset as GameObject;
                        obj = Instantiate(player);
                        anim = obj.GetComponent<Animator>();
                    });
                    refSet.Load();
                }
            }

            if (obj != null)
            {
                if (Input.GetKeyDown(KeyCode.K))
                {
                    AudioManager.PlayVoice(audioEvent);
                    if (anim != null)
                    {
                        anim.StartMouthAnimation(audioEvent);
                    }
                }
            }
        }
    }


}
